<?php
/**
 * 物流公司（基础）
 * (model)
 */

namespace App\Models\Basics;

use Illuminate\Database\Eloquent\Model;
class ExpressCompany extends Model
{
    protected $table = 'b_express_company';

    public $timestamps = false;

    protected $guarded = [];

    public static function options($where = null, $column1 = 'name', $column2 = 'id'){
        $query = $where ? self::query()->where(formatCondition($where)) : self::query();
        return $query->pluck($column1,$column2);
    }

    public static function existById($id){
        $count = self::query()->where('id',$id)->count();
        return $count > 0 ? true : false;
    }

    public static function getNameById($id){
        return self::query()->where('id',$id)->value('name');
    }

    public static function getIdByName($name){
        return self::query()->where('name',$name)->value('id');
    }

    public static function getModel($id){
        return self::query()->where('id',$id)->first();
    }

}
